<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class BistroIncomeDay extends Model
{
    //
    protected $table = 'bistro_income_days';

    protected $fillable = [
        'bistro_id', 'date', 'income', 'outcome'
    ];

    public function scopeDate($query, $date){
        if(!empty($date)) {
            return $query->where('date', $date);
        }
        return $query;
    }

    public function scopeDateFrom($query, $date_start, $date_end) {
        if(!empty($date_start) && !empty($date_end)) {
            $query->where('date', '>=', $date_start)->where('date', '<=', $date_end);
        }
        return $query;
    }

    public function scopeBistroId($query, $bistro_id) {
        if(!empty($bistro_id)) {
            return $query->where('bistro_id', $bistro_id);
        }
        return $query;
    }
}
